package cn.yllr.tomgxianghui.service.impl;


import cn.yllr.tomgxianghui.dao.AppointmentMapper;
import cn.yllr.tomgxianghui.domain.Appointment;
import cn.yllr.tomgxianghui.service.AppointmentService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


@Service
@Transactional
public class AppointmentServiceImpl implements AppointmentService {

    @Resource
    private AppointmentMapper mapper;

    /**
     * 预约厨师
     *
     * @param orderid
     * @param customerid
     * @param cookid
     * @param date
     * @return
     */
    @Override
    public Boolean addAp(String orderid, String customerid, String cookid, String date) {
        return mapper.addappoint(orderid, customerid, cookid, date,0);
    }

    /**
     * 查找预约信息
     *
     * @return
     */
    @Override
    public List<Appointment> findappoint() {
        return mapper.findap();
    }

    /**
     * 根据账户查找预约信息
     * @param name
     * @return
     */
    @Override
    public List<Appointment> findappointmentByOid(String name) {
        return null;
    }

    /**
     * 更新订单状态等于2，表示厨师已经受理订单，1表示未受理，0表示已过期
     * @param orderid
     * @return
     */
    @Override
    public int updateOrderstatus(String orderid) {
        return mapper.updateorderstatusBecooker(orderid);
    }

    /**
     * 查找用户的订单根据id
     * @param cid
     * @return
     */
    @Override
    public List<Appointment> findappointByCid(String cid) {
        return mapper.findappointbycid(cid);
    }

    @Override
    public List<Appointment> findappointByCookid(String cookid) {
        return mapper.findappointbycookid(cookid);
    }

    /**
     * 同意预约信息，把状态位改为1
     * @param orderid
     * @return
     */
    @Override
    public int agreeAppoint(String orderid) {
        return mapper.agreeappoint(orderid);
    }

    /**
     * 厨师拒绝预约，把状态位改为2
     * @param orderid
     * @return
     */
    @Override
    public int refuseAppoint(String orderid) {
        return mapper.refuseappoint(orderid);
    }

    @Override
    public int reAppoint(String orderid) {
        return mapper.reappoint(orderid);
    }

}

